import gtk
import account

class accountWizard():
    def __init__(self):
        builder = gtk.Builder()
        builder.add_from_file("ui/myaccountwizard.glade")
        builder.connect_signals(self)
        self._window = builder.get_object("accountWizardAssistant")
        self._window.show()
        self._usernameEntry = builder.get_object("usernameEntry")
        
    def on_accountWizardAssistant_destroy(self,widget,data=None):
        self._window.destroy()
    
    def on_accountWizardAssistant_cancel(self,widget,data=None):
        self._window.destroy()
    
    def on_accountWizardAssistant_close(self,widget,data=None):
        account.createNewMyAccount(self._usernameEntry.get_text())
        self._window.destroy()
    
    def on_accountWizardAssistant_prepare(self,widget,data=None):
        cur = self._window.get_current_page()
        if cur == 0:
            self._window.set_page_complete(self._window.get_nth_page(0),True)
            
    def on_usernameEntry_changed(self,widget,data=None):
        if len(widget.get_text()) > 0:
            self._window.set_page_complete(self._window.get_nth_page(1),True)
            self._window.set_page_complete(self._window.get_nth_page(2),True)
            
